package cn.deathgun.dcswebspringboot.controller

import cn.deathgun.dcswebspringboot.entity.PlayerEntity
import cn.deathgun.dcswebspringboot.service.impl.PlayerServiceImpl
import jakarta.annotation.Resource
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("/players")
class PlayerController(@Resource private val playerService:PlayerServiceImpl) {

    @GetMapping("/all")
    fun listAll(): List<PlayerEntity> = playerService.getPlayers()

    @GetMapping("/search/playerName={name}")
    fun listPlayerByName(@PathVariable name:String): List<PlayerEntity>
    = playerService.searchPlayer(name)

}
